//
//  CustomViewController.swift
//  Animator
//
//  Created by liu guoqiang on 16/9/11.
//  Copyright © 2016年 liu guoqiang. All rights reserved.
//

import UIKit

class CustomViewController: UIViewController ,UINavigationControllerDelegate,UIViewControllerTransitioningDelegate{

    override func viewDidLoad() {
        super.viewDidLoad()
        self.navigationController?.delegate = self
        self.transitioningDelegate = self
    }
    
    @IBAction func treeClick(sender: AnyObject) {
        let VC = UIGravityViewController()
        self.navigationController?.showViewController(VC, sender: nil)
    }

    @IBAction func presentClick(sender: AnyObject) {
        let VC = UIGravityViewController()
        self .presentViewController(VC, animated: true) { 
            print("过渡完成")
        }
        
    }
    
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
       
            let destionViewController = segue.destinationViewController as UIViewController
            destionViewController.transitioningDelegate = self
    }
    
    func animationControllerForPresentedController(presented: UIViewController, presentingController presenting: UIViewController, sourceController source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        let animator = SlideTransitionAnimator()
        return animator
    }
    
    func animationControllerForDismissedController(dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        let animator = SlideTransitionAnimator()
        return animator
    }
  
     func navigationController(navigationController: UINavigationController, animationControllerForOperation operation: UINavigationControllerOperation, fromViewController fromVC: UIViewController, toViewController toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        let animator = SlideTransitionAnimator()
        return animator
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
    
}
